package com.hethongviet.job.pages;

import com.hethongviet.job.AppMain;
import com.hethongviet.job.JobTrackingActivity;
import com.hethongviet.job.R;
import com.hethongviet.job.helpers.TabMenu;
import com.hethongviet.job.models.Tab;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DetailTaskActivity extends Activity
{
	private static final int TOTAL_TABS = 3;

	private LinearLayout _linearLayoutDetail = null;
	private LinearLayout _linearLayoutListComments = null;
	private LinearLayout _linearLayoutListFilesAttached = null;

	private TabMenu _tabMenu = null;
 
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		AppMain.makeFullScreen(this);

		setContentView(R.layout.page_detail_task);

		final TextView textProjectName = (TextView) findViewById(R.id.textProjectName);
		final TextView textProjectDescription = (TextView) findViewById(R.id.textProjectDecription);

		final Button buttonUsername = (Button) findViewById(R.id.buttonUsername);
		buttonUsername.setText(AppMain._user.getUsername());
		buttonUsername.setOnClickListener(new OnClickListener() {
			public void onClick(View v)
			{
				/*Logout*/
				Intent intent = new Intent(DetailTaskActivity.this, JobTrackingActivity.class);
				startActivity(intent); 
			}
		});
		
		if(textProjectName == null)
		{
			Log.d("debug", "2222222222222222222");
		}
		if(AppMain._currentProject == null)
		{
			Log.d("debug", "2222222222222222222111");
		}
		
		textProjectName.setText(AppMain._currentProject.getName());
		textProjectDescription.setText(AppMain._currentProject.getDescription());

		final Button buttonTabDetail = (Button) findViewById(R.id.buttonTabDetail);
		final Button buttonTabListComments = (Button) findViewById(R.id.buttonTabListComments);
		final Button buttonTabListFilesAttached = (Button) findViewById(R.id.buttonTabListFileAttached);

		_linearLayoutDetail = (LinearLayout) findViewById(R.id.layoutTabDetails);
		_linearLayoutListComments = (LinearLayout) findViewById(R.id.layoutTabListComments);
		_linearLayoutListFilesAttached = (LinearLayout) findViewById(R.id.layoutTabListFilesAttached);

		Tab[] tabs = new Tab[TOTAL_TABS];
		for (int i = 0; i < TOTAL_TABS; i++)
		{
			tabs[i] = new Tab();
		}
		tabs[0].setButton(buttonTabDetail);
		tabs[0].setButtonFunctions(null);
		tabs[0].setLinearLayout(_linearLayoutDetail);
		tabs[1].setButton(buttonTabListComments);
		tabs[1].setButtonFunctions(null);
		tabs[1].setLinearLayout(_linearLayoutListComments);
		tabs[2].setButton(buttonTabListFilesAttached);
		tabs[2].setButtonFunctions(null);
		tabs[2].setLinearLayout(_linearLayoutListFilesAttached);

		_tabMenu = new TabMenu(tabs, R.drawable.button_tab_2,
				R.drawable.button_tab_highlight_2);

	}
}
